package com.ryan.spring.annotation.collection;

import java.util.Arrays;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Hashtable;

/**
 * Created by kaimin on 31/1/2019.
 * time : 14:50
 */
public class CompareMain {
    public static void main(String[] args) {
        Student student = new Student(12);
        Student student1 = new Student(13);

        System.out.println(student);
        Student[] students = {new Student(12), new Student(13)};

        for (Student st : students) {
            System.out.println(st.getAge());
        }

        System.out.println("-------");
        Arrays.sort(students);

        for (Student st : students) {
            System.out.println(st.getAge());
        }


        System.out.println("-------");
        Arrays.sort(students, new StudentComparor());

        for (Student st : students) {
            System.out.println(st.getAge());
        }

        HashMap<Object, Object> objectObjectHashMap = new HashMap<>();
        objectObjectHashMap.put(null,1);
        objectObjectHashMap.put(2,null);
        objectObjectHashMap.put(null,null);
        objectObjectHashMap.forEach((k,v)->{
            System.out.println(k+" "+v);
        });

        try {
            Student clone = (Student) student.clone();
            System.out.println(clone.getAge());
        } catch (CloneNotSupportedException e) {
            e.printStackTrace();
        }

        Hashtable<Object, Object> hashtable = new Hashtable<>();
        hashtable.put(1,1);
//        hashtable.put(2,null);
        hashtable.forEach((k,v)->{
            System.out.println(k+" "+v);
        });
    }
}
